<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
<!--          <template v-if="toggleSearchStatus">-->
<!--            <a-col :md="6" :sm="8">-->
<!--              <a-form-item label="入库单编号">-->
<!--                <a-date-picker placeholder="请输入入库单编号" v-model="queryParam.orderNumber"></a-date-picker>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
            <a-col :md="6" :sm="8">
              <a-form-item label="中文品牌">
                <j-input placeholder="请输入供货商单位" v-model="queryParam.brand"></j-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="车辆类型">
                <j-input placeholder="请输入车辆状态" v-model="queryParam.carModel"></j-input>
              </a-form-item>
            </a-col>
<!--          </template>-->
          <a-col :md="6" :sm="8">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button
                type="primary"
                @click="searchReset"
                icon="reload"
                style="margin-left: 8px"
              >重置</a-button>
<!--              <a @click="handleToggleSearch" style="margin-left: 8px">-->
<!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
<!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>-->
<!--              </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!--<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
<!--      <a-button type="primary" icon="download" @click="handleExportXls('cxm-订单记录信息')">导出</a-button>-->
<!--      <a-upload-->
<!--        name="file"-->
<!--        :showUploadList="false"-->
<!--        :multiple="false"-->
<!--        :headers="tokenHeader"-->
<!--        :action="importExcelUrl"-->
<!--        @change="handleImportExcel"-->
<!--      >-->
<!--        <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
        :scroll="{ x: 2000 }"
      >
        <span slot="action" slot-scope="text, record">
          <a-button type="primary" @click="handleLook(record)">查看详情</a-button>
          <a-button @click="handleEdit2(record, 2)" style="margin: 0 10px 0 ">修改</a-button>
        </span>
        <span
          slot="filterDepositAttribute"
          slot-scope="depositAttribute"
        >{{ depositAttribute | filterDepositAttribute(depositAttribute) }}</span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <!-- <cxmOrderManager-modal ref="modalForm" @ok="modalFormOk"></cxmOrderManager-modal> -->
    <pricing-model ref="modalForm" @ok="modalFormOk"></pricing-model>
  </a-card>
</template>

<script>
  import PricingModel from './PricingModel.vue'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JInput from '@/components/jeecg/JInput'
  import moment from 'moment'
  import { USER_INFO } from '@/store/mutation-types'
  import Vue from 'vue'
  import { getAction } from '@/api/manage'

  export default {
    name: 'Pricing',
    mixins: [JeecgListMixin],
    components: {
      PricingModel,
      JInput,
      moment
    },
    data() {
      return {
        description: 'cxm-订单管理页面',
        visible: false,
        // 表头
        loading: '',
        dataSources: [],
        columns: [
          // {
          //   title: 'id',
          //   align: 'center',
          //   dataIndex: 'id'
          // },
          {
            title: '入库时间',
            align: 'center',
            dataIndex: 'storageTime'
          },
          // {
          //   title: '供货单位名称',
          //   align: 'center',
          //   dataIndex: 'supplier',
          //   width: 200
          // },
          {
            title: '中文品牌',
            align: 'center',
            dataIndex: 'brand'
          },
          {
            title: '车辆型号',
            align: 'center',
            dataIndex: 'carModel'
          },
          {
            title: '车辆识别代码(VIN)',
            align: 'center',
            dataIndex: 'vin'
          },
          {
            title: '合格证编号',
            align: 'center',
            dataIndex: 'certificateNo'
          },
          {
            title: '进价(元)',
            align: 'center',
            dataIndex: 'carCost'
          },
          {
            title: '运费(元)',
            align: 'center',
            dataIndex: 'freightCost'
          },
          {
            title: '选装费(元)',
            align: 'center',
            dataIndex: 'decorateCost'
          },
          {
            title: '厂商指导价(元)',
            align: 'center',
            dataIndex: 'directorPrice'
          },
          {
            title: '状态',
            align: 'center',
            dataIndex: 'status'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            width: 260,
            fixed: 'right',
            scopedSlots: {
              customRender: 'action'
            }
          }
        ],

        url: {
          list: '/sale/cxmSaleCarInfo/list',
          delete: '/cxm/cxmOrderManager/delete',
          deleteBatch: '/cxm/cxmOrderManager/deleteBatch',
          exportXlsUrl: 'cxm/cxmOrderManager/exportXls',
          importExcelUrl: '/sale/cxmSaleCarInfo/list'
        },
        fuelType:''
      }
    },
    computed: {
      importExcelUrl: function() {
        return `${process.env.VUE_APP_BASE_API}/${this.url.importExcelUrl}`
      }
    },
    methods: {
      handleLook(record) {
        console.log(record);
        if(this.$refs.modalForm.add){
          this.$refs.modalForm.add(record);
        }else{
          this.$refs.modalForm.add = function (depart) {
            if (depart) {
              this.dictDisabled = false;
            } else {
              this.dictDisabled = true;
            }
            this.edit(depart);
          }
          this.$refs.modalForm.add(record);
        }
        this.$refs.modalForm.title = "查看";
        this.$refs.modalForm.disableSubmit = false;
      },
      getPrcingNum() {
        this.axios.get(this.importExcelUrl
        ).then(res => {
          let rs = res.result
          console.log(res)
        }).catch(err => {
          // this.expRoute("2",err.message)
        })
      }
    },
    mounted() {
      this.getPrcingNum()
    },
    filters: {
      filterTime(time) {
        return moment(time).format('YYYY-MM-DD')
      },
      filterDepositAttribute(depositAttribute) {
        switch (depositAttribute) {
          case '1':
            return '可退'
            break
          case '2':
            return '不可退'
            break
          case '3':
            return '有条件可退'
            break
        }
      }
    }
  }
</script>
<style scoped>
  @import "~@assets/less/common.less";
</style>
